﻿<Page x:Class="SoftTeach.View.Stundenentwürfe.MetroStundenentwurfDetailPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:converter="clr-namespace:SoftTeach.Resources.Converter"
      xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
      xmlns:pb="clr-namespace:SoftTeach.ViewModel.Helper.PushBinding"
      xmlns:softTeach="clr-namespace:SoftTeach"
      mc:Ignorable="d" 
      d:DesignHeight="768" 
      d:DesignWidth="1366"
      Title="Stundenentwurf"
      FontSize="20">
  <Page.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/SoftTeach;component/Resources/MetroResources.xaml"/>
        <ResourceDictionary >
          <!-- Value Converters -->
          <converter:IgnoreNewItemPlaceHolderConverter x:Key="IgnoreNewItemPlaceHolderConverter"/>
        </ResourceDictionary>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Page.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
      <RowDefinition Height="Auto" MinHeight="100"/>
    </Grid.RowDefinitions>
    <Border Grid.Row="0" Background="{StaticResource MetroHeaderBackground}">
      <Label Content="{Binding StundeMetroTitel}" Foreground="White"/>
    </Border>
    <Grid Grid.Row="1" x:Name="TopGrid" Margin="5,3">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
      </Grid.ColumnDefinitions>
      <TextBox Grid.Row="0" Grid.Column="0" Style="{StaticResource Header1}" Text="{Binding Path=StundeStundenentwurf.StundenentwurfStundenthema}">
        <TextBox.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="White" Offset="0.664" />
            <GradientStop Color="#FFF8F8F8" Offset="0" />
          </LinearGradientBrush>
        </TextBox.Background>
      </TextBox>
      <ComboBox Grid.Row="1" Grid.Column="0" SelectedValuePath="." 
                    SelectedItem="{Binding Path=StundeStundenentwurf.StundenentwurfModul}" 
                    ItemsSource="{Binding Path=StundeStundenentwurf.ModulView}" 
                    DisplayMemberPath="ModulBezeichnung"
                    HorizontalAlignment="Stretch"
                    Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/>
      <StackPanel Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Orientation="Horizontal">
        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=StundeStundenentwurf.AddDateiverweisCommand}">
          <StackPanel Orientation="Horizontal" ToolTip="Datei hinzufügen">
            <Grid >
              <Image Source="/SoftTeach;component/Images/Dateityp32.png"/>
              <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
            </Grid>
          </StackPanel>
        </Button>

        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=StundeStundenentwurf.DeleteDateiverweisCommand}">
          <StackPanel Orientation="Horizontal" ToolTip="Datei entfernen">
            <Grid >
              <Image Source="/SoftTeach;component/Images/Dateityp32.png"/>
              <Image Source="/SoftTeach;component/Images/RemoveOverlay32.png"/>
            </Grid>
          </StackPanel>
        </Button>
      </StackPanel>
      <ListView Grid.Row="0" Grid.Column="2" Grid.RowSpan="2"
                SelectedItem="{Binding Path=StundeStundenentwurf.CurrentDateiverweis, Mode=TwoWay}" 
                ItemsSource="{Binding Path=StundeStundenentwurf.Dateiverweise}"
                ItemTemplate="{StaticResource DateiverweiseListViewTile}"
                Background="Transparent" 
                BorderBrush="Transparent" 
                BorderThickness="0">
        <ListView.ItemsPanel>
          <ItemsPanelTemplate>
            <WrapPanel Orientation="Horizontal"/>
          </ItemsPanelTemplate>
        </ListView.ItemsPanel>
      </ListView>
    </Grid>
    <Grid Grid.Row="2">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <Grid Grid.Row="0" Background="{StaticResource MetroHeaderBackground}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0" >
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
          </Grid.ColumnDefinitions>
          <Label Grid.Column="0">Phasen</Label>
          <Button Grid.Column="1" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=StundeStundenentwurf.MovePhaseCommand}">
            <StackPanel Orientation="Horizontal" ToolTip="Phase verschieben">
              <Grid >
                <Image Source="/SoftTeach;component/Images/Phase16.png"/>
                <Image Source="/SoftTeach;component/Images/MoveOverlay16.png"/>
              </Grid>
              <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Phase in nächste Stunde verschieben.</Label>

            </StackPanel>
          </Button>
          <Label Grid.Column="2">Verplante Minuten:</Label>
          <Label Grid.Column="3" Content="{Binding Path=StundeStundenentwurf.StundenentwurfVerplanteMinutenVonAllen}" Background="{Binding Path=StundeStundenentwurf.StundentwurfMinutenCheckBrush}"/>
        </Grid>
      </Grid>
      <!--CellStyle="{StaticResource CellDirectClickStyle}"-->
      <DataGrid Grid.Row="1" 
                SelectedItem="{Binding Path=StundeStundenentwurf.CurrentPhase, Converter={StaticResource IgnoreNewItemPlaceHolderConverter}}" 
                ItemsSource="{Binding Path=StundeStundenentwurf.PhasenView}" 
                AutoGenerateColumns="False"
                HorizontalScrollBarVisibility="Disabled"
                Name="PhasenGrid"
                dd:DragDrop.IsDragSource="True" 
                dd:DragDrop.IsDropTarget="True"
                dd:DragDrop.DragAdornerTemplate="{StaticResource PhaseDragAdorner}"
                dd:DragDrop.DropHandler="{Binding}" 
                HeadersVisibility="None"
                SelectionMode="Extended">
        <pb:PushBindingManager.PushBindings>
          <pb:PushBinding TargetProperty="SelectedItems" Path="StundeStundenentwurf.SelectedPhasen"/>
        </pb:PushBindingManager.PushBindings>
        <DataGrid.InputBindings>
          <KeyBinding Modifiers="Control" Key="C" Command="{Binding Path=StundeStundenentwurf.CopyCommand}"/>
          <KeyBinding Modifiers="Control" Key="V" Command="{Binding Path=StundeStundenentwurf.PasteCommand}"/>
        </DataGrid.InputBindings>
        <DataGrid.Columns>
          <DataGridTextColumn Header="Zeit" Binding="{Binding Path=PhaseZeit, UpdateSourceTrigger=PropertyChanged}" CanUserSort="False"/>
          <DataGridComboBoxColumn 
                        Header="Medien" 
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Medien}"
                        SelectedItemBinding="{Binding Path=PhaseMedium}" 
                        DisplayMemberPath="MediumBezeichnung" CanUserSort="False" 
                        EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"/>
          <DataGridComboBoxColumn 
                        Header="Sozialform" 
                        SelectedItemBinding="{Binding Path=PhaseSozialform}" 
                        DisplayMemberPath="SozialformBezeichnung"
                        EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Sozialformen}" CanUserSort="False" />
          <DataGridTextColumn Header="Inhalt" Binding="{Binding Path=PhaseInhalt}" Width="*" CanUserSort="False"
                            ElementStyle="{StaticResource DatagridMultilineElementStyle}"
                            EditingElementStyle="{StaticResource DatagridMultilineEditingElementStyle}"/>
        </DataGrid.Columns>
      </DataGrid>
    </Grid>
    <Grid Grid.Row="3" x:Name="BottomGrid">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition Width="Auto"/>
      </Grid.ColumnDefinitions>
      <Label Grid.Row="0" Grid.Column="0" Background="{StaticResource MetroHeaderBackground}">Hausaufgaben</Label>
      <TextBox Grid.Row="1" Grid.Column="0" Name="HausaufgabenTextBox" Text="{Binding Path=StundeStundenentwurf.StundenentwurfHausaufgaben}"
                   TextWrapping="Wrap"
                   AcceptsReturn="True"/>
      <Label Grid.Row="0" Grid.Column="1" Background="{StaticResource MetroHeaderBackground}">Termine/Ansagen</Label>
      <TextBox  Grid.Row="1" Grid.Column="1" Name="TermineTextBox" Text="{Binding Path=StundeStundenentwurf.StundenentwurfAnsagen}"
                   TextWrapping="Wrap"
                   AcceptsReturn="True"/>
      <Label Grid.Row="0" Grid.Column="2" Background="{StaticResource MetroHeaderBackground}">Sonstiges</Label>
      <StackPanel Grid.Row="1" Grid.Column="2" Margin="3" >
        <CheckBox Content="Kopieren" Height="32" Name="KopierenCheckBox" IsChecked="{Binding Path=StundeStundenentwurf.StundenentwurfKopieren}"/>
        <CheckBox Content="Computer" Height="32" Name="ComputerCheckBox" IsChecked="{Binding Path=StundeStundenentwurf.StundenentwurfComputer}"/>
      </StackPanel>
    </Grid>
  </Grid>
</Page>
